8a3a9b6323a25a2e92b30d6f1348257243979516,src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java,PhraseTable,readPhrasesWithTagScores,#String#Pattern#Pattern#,178

Before Change


      Counter<String> counts = new ClassicCounter<String>(mapFactory);
      for (int i = 1; i < columns.length; i++) {
        String[] tagCount = fieldDelimiterPattern.split(columns[i]);
        counts.setCount(tagCount[0], Double.parseDouble(tagCount[1]));
      }
      addPhrase(phrase, null, counts);
    }

After Change


    timer.doing("Reading phrases: " + filename);
    BufferedReader br = IOUtils.getBufferedFileReader(filename);
    String line;
    int lineno = 0;
    while ((line = br.readLine()) != null) {
      String[] columns = fieldDelimiterPattern.split(line);
      String phrase = columns[0];
      // Pick map factory to use depending on number of tags we have
      MapFactory<String,MutableDouble> mapFactory = (columns.length < 20)?
              MapFactory.<String,MutableDouble>arrayMapFactory(): MapFactory.<String,MutableDouble>linkedHashMapFactory();
      Counter<String> counts = new ClassicCounter<String>(mapFactory);
      for (int i = 1; i < columns.length; i++) {
        String[] tagCount = countDelimiterPattern.split(columns[i], 2);
        if (tagCount.length == 2) {
          try {
            counts.setCount(tagCount[0], Double.parseDouble(tagCount[1]));
          } catch (NumberFormatException ex) {
            throw new RuntimeException("Error processing field " + i + ": '" + columns[i] +
                    "' from (" + filename + ":" + lineno + "): " + line, ex);
          }
        } else {
          throw new RuntimeException("Error processing field " + i + ": '" + columns[i] +
                  "' from + (" + filename + ":" + lineno + "): " + line);
        }
      }
      addPhrase(phrase, null, counts);